<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        function Map() {
            var obj = {};
            this.put = function(key,value){
                obj[key] = value
            }
            //获得map的个数
            this.size = function(){
                var count = 0;
                for(var attr in obj){
                    count++;
                }
                return count;
            }
            this.get = function(key){
                if(obj[key] || obj[key]===0 || obj[key]===false){
                    return obj[key];
                }else{
                    return null;
                }
            }
            this.remove = function(key){
                if(obj[key] || obj[key]===0 || obj[key]===false){
                    delete obj[key];
                }
            }
            /**
             *
             * @param fn回掉函数
             */
            this.eachMap = function(fn){
                for(var attr in obj){
                    fn(attr,obj[attr]);
                }
            }
        }
        var map = new Map();
        map.put("01","abc");
        map.put("02",0);
        map.put("03",true);
        map.put("04",new Date());
        //alert(map.size());
        //alert(map.get("02"));
        //map.remove("03");
        //alert(map.get("03"));
        map.eachMap(function(key,value){
            alert(key+":"+value);
        });
    </script>
</head>
<body>
</body>
</html>